package unei.net.nio;

import java.util.concurrent.*;

/**
 * Created by sunlei on 2015/8/31.
 */
public class NioConnector {
    private static Executor executor=createExecutor();

    public NioConnector(){

    }

    private static Executor createExecutor(){
        ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(10, 1500, 30, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new ThreadFactory() {
            private int i=0;

            public Thread newThread(Runnable r) {
                this.i++;
                final Thread t=new Thread(r,"Connector worker "+i);
                return t;
            }
        });

        return threadPoolExecutor;
    }

    public static Executor getExecutor() {
        return executor;
    }

}
